package com.edu.model;

import java.io.Serializable;
import java.util.Date;

/**
 * @author CharChen
 * @e-mail piggsoft@163.com
 * @since 2013-5-16
 * @version 1.0
 */
public abstract class Entity<K extends Serializable> implements Serializable, Comparable<Entity<K>>{

	/**
	 * 
	 */
	private static final long serialVersionUID = -7866006692757097414L;
	
	protected K id;

	public K getId() {
		return id;
	}

	public void setId(K id) {
		this.id = id;
	}
	
	@Override
	public int hashCode() {
		return getId().hashCode();
	}
	
	@Override
	public int compareTo(Entity<K> entity) {
		if (this.getClass().getSimpleName().equals(entity.getClass().getSimpleName())) {
			return this.hashCode() - entity.hashCode();
		}
		return 0;
	}
	
	protected String creator;
	protected Date createTime;
	protected String updater;
	protected Date updateTime;

	public String getCreator() {
		return creator;
	}

	public void setCreator(String creator) {
		this.creator = creator;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public String getUpdater() {
		return updater;
	}

	public void setUpdater(String updater) {
		this.updater = updater;
	}

	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}
}
